package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.domain.vo.TableVo;
import com.ruoyi.common.service.TableService;
import com.ruoyi.hqfinance.domain.HqCostSubject;
import com.ruoyi.hqfinance.domain.HqNavigationPolicy;
import com.ruoyi.hqfinance.domain.vo.HqNavigationPolicyVo;
import com.ruoyi.hqfinance.service.HqCostSubjectService;
import com.ruoyi.hqfinance.service.HqNavigationPolicyService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/hq/navigationPolicy")
@Api(tags = "总部财务-航海政策结算报表")
public class HqNavigationPolicyController {
    @Autowired
    private HqNavigationPolicyService hqNavigationPolicyService;
    @Autowired
    private TableService tableService;

    @ApiOperation("网点综合费用结算")
    @PostMapping("/searchComprehensive")
    public R searchComprehensive(@RequestBody HqNavigationPolicyVo vo) {
        List<HqNavigationPolicy> list = hqNavigationPolicyService.search(vo);
        List<TableVo> fieldList = tableService.getFieldAnnotation(new HqNavigationPolicy());
        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
        jsonObject.put("list", PageInfo.info(list));
        jsonObject.put("fields", fieldList);
        if (list == null || list.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(jsonObject);
        }
    }
}


